"""
Copyright © 2021 Walkline Wang (https://walkline.wang)
Gitee: https://gitee.com/walkline/iot-explorer-sdk-for-micropython
"""
import random


class Utilities(object):
	ASCII_LETTERS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
	DIGITS = '0123456789'

	@staticmethod
	def soft_reset():
		from sys import exit
		exit()

	@staticmethod
	def hard_reset():
		from machine import reset
		reset()

	@staticmethod
	def get_random_sample(length):
		'''
		随机生成指定长度大小写字母与数字组合的字符串
		'''
		return ''.join(random.choice(Utilities.ASCII_LETTERS+ Utilities.DIGITS) for _ in range(length))

	@staticmethod
	def get_random_nonce():
		return random.randrange(2147483647)
